﻿grammar FuzzyJava;
 
/** Match anything in between constant rule matches */
file : .*? (constant .*?)+ ;
 
/** Faster alternate version (Gets an ANTLR tool warning about
 * a subrule like .* in parser that you can ignore.)
 */
altfile : (constant | .)* ; // match a constant or any token, 0-or-more times

/** Match things like "public static final SIZE" followed by anything */
constant
    :   'public' 'static' 'final' 'int' Identifier
        {System.out.println("constant: "+$Identifier.text);
         System.out.println("constant line num: "+$Identifier.line);
         System.out.println("constant position: "+$Identifier.pos);
         System.out.println("constant type: "+$Identifier.type);
         System.out.println("constant channel: "+$Identifier.channel);
         System.out.println("text : "+$text);
         System.out.println("first token : "+$start.getText());
         if ( $stop!=null ) 
         	System.out.println("last token : "+$stop.getText());
         System.out.println("first token2 : "+$ctx.start.getText());
         }//https://gitee.com/lingxw-sh/antlr4/blob/master/doc/actions.md
    ;
 
Identifier : [a-zA-Z_$] [a-zA-Z_$0-9]* ; // simplified
OTHER : . -> skip ;